package com.example.spring3.config;

import lombok.SneakyThrows;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

@Configuration
@ComponentScan(value = "com.example.spring3")
public class SpringConfig {
    @Bean
    public Connection getConnection(JdbcPropertis jdbcPropertis) throws ClassNotFoundException, SQLException {
        Class.forName(jdbcPropertis.getDriver());
        return DriverManager.getConnection(jdbcPropertis.getUrl(), jdbcPropertis.getUsername(), jdbcPropertis.getPassword());
    }

}
